package cn.edu.scau.cmi.dengzejun.chapter11;

import java.awt.*;
import javax.swing.*;

public class ComponentInWindow extends JFrame{
	JTextField text;
	JButton	button;
	JCheckBox	checkBox1,checkBox2,checkBox3;
	JRadioButton	radio1,radio2;
	ButtonGroup	group;
	JComboBox	comBox;
	JTextArea	area;
	
	public ComponentInWindow() {
		init();
		this.setVisible(true);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}
	
	private void init() {
		this.setLayout(new FlowLayout());
		this.add(new JLabel("Text"));
		this.text = new JTextField(10);
		this.add(text);
		this.add(new JLabel("Botton"));
		this.button = new JButton("Sure");
		this.add(this.button);
		this.add(new JLabel("Choose Field"));
		this.checkBox1 = new JCheckBox("like music");
		this.checkBox2 = new JCheckBox("like travel");
		this.checkBox3 = new JCheckBox("like basketball");
		this.add(this.checkBox1);
		this.add(this.checkBox2);
		this.add(this.checkBox3);
		this.add(new JLabel("Single selection Button"));
		this.group = new ButtonGroup();
		this.radio1 = new JRadioButton("male");
		this.radio2 = new JRadioButton("female");
		this.group.add(radio1);
		this.group.add(radio2);
		this.add(radio1);
		this.add(radio2);
		this.add(new JLabel("drop-down list"));
		this.comBox = new JComboBox();
		this.comBox.addItem("music");
		this.comBox.addItem("wushu");
		this.comBox.addItem("chess");
		this.add(comBox);
		this.add(new JLabel("Text area"));
		this.area = new JTextArea(6,12);
		this.add(new JScrollPane(area));
		return;
	}
}
